package com.steveguren.zookeeper.manager;

import java.util.Date;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.zookeeper.CreateMode;

public class ClientCreate {

	public static String zookeeperConnectionString = "172.20.110.74:2181,172.20.110.80:2181,172.20.110.94:2181";

	public static String path = "/steve/test";
	public static void main(String[] args) {
		RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
		CuratorFramework client = CuratorFrameworkFactory.newClient(zookeeperConnectionString, retryPolicy);
		client.start();
		System.out.println(new Date().getTime());
		try {
			for(int i = 0; i < 1000; i++) {
				System.out.println(client.create()
						.creatingParentsIfNeeded()
						.withMode(CreateMode.PERSISTENT_SEQUENTIAL)
						.forPath(path));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(new Date().getTime());
	}
}
